package com.merry.sb.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.merry.sb.mapper.MyMapper;
import com.merry.sb.vo.PageVO;
import com.merry.sb.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyService {
    @Autowired
    MyMapper mapper;

    public PageInfo<User> queryWithPage(PageVO vo) {
        // 开始分页
        PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        // 查询
        List<User> userList = mapper.getUserList();
        // 封装分页对象
        PageInfo<User> pageInfo = new PageInfo<>(userList);
        return pageInfo;
    }
}
